home *** CD-ROM | disk | FTP | other *** search
- vc.lib - C library for the Amiga68k version of vbcc
-
-
- INTRODUCTION
-
- vc.lib is a (rather) ANSI compliant C library for use with the
- Amiga68k version of vbcc.
-
- It is written largely in C and some parts are not Amiga specific.
-
- You can also create a small data library (this one will probably
- be in the archive already as vcs.lib), a small-code-version, a
- 020-version etc. or combinations of this (see COMPILING).
-
- Note that you have to link with a math library if you want to use
- floating point. All math functions, special startup code and
- printf/scanf functions which support floating point are contained in
- the math libraries only.
- At the moment there are four math libraries:
-
- mieee.lib This one uses the C= math libraries. The startup code
- will always open MathIeeeSingBas.library,
- MathIeeeDoubBas.library and MathIeeeDoubTrans.library.
- Float return values are passed in d0, double return
- values are passed in d0/d1.
- A 68000 is sufficient to use this library.
- You must not specify -fpu=... when you use this library.
-
- m881.lib This one uses direct FPU instructions and function
- return values are passed in fp0. You must have a
- 68020 or higher and an FPU to use this library. You
- also have to specify -fpu=68881.
- Several FPU instructions that have to be emulated on
- 040/060 may be used.
-
- m040.lib This one uses only direct FPU instructions that do not
- have to be emulated on a 040/060. Other functions use
- the Motorola emulation routines modified by
- Aki M Laukkanen.
- It should be used for programs compiled for 040 or 060
- with FPU and replaces the former m040.lib which is now
- called m040o.lib.
- Return values are passed in fp0.
-
- m040o.lib This one uses only direct FPU instructions that do not
- have to be emulated on a 68040. For unsupported
- functions the MathIeee-libraries are called.
- Unfortunately the current C=-libraries still use the
- unsupported instructions, but there are replacement
- libraries available e.g. on aminet.
- Return values are passed in fp0.
- This library should be obsolete.
-
-
- To link with one of those libraries add e.g. the -lmieee option to vc or
- specify mieee.lib before vc.lib if you do the linking by hand.
-
- Some info about amiga.lib can be found in fd2lib.doc.
-
-
- LEGAL
-
- vc.lib is public domain. Certain parts have been taken from other
- PD libraries (mainly libnix).
- The same applies to m881.lib, m040.lib and mieee.lib.
-
-
- STARTUP etc.
-
- The startup code currently consists of a slightly modified standard
- Amiga startup and the file _main.c. The startup code sets up some
- global variables and initializes stdin, stdout and stderr.
- The exit code closes all open files and frees all memory.
- If you link with a math library the startup/exit code will be taken
- from there if necessary.
-
-
- INLINING
-
- Several header-files provide support for inlining of certain library
- functions. If the preprocessor-symbol __INLINE_<function> is defined
- the corresponding function may be inlined. E.g if you compile with
-
- vc -O3 -D__INLINE_STRCPY
-
- then calls to strcpy() will be inlined. Note however that the symbol
- must be defined at the time string.h is included and, of course, that
- function inlining must be turned on.
-
- Not all library functions are prepared for inlining but only those
- that are reasonably small, are not implemented as macros and can
- safely be inlined. E.g. __INLINE_QSORT will be ignored.
-
- The symbol __INLINE_ALL will cause inlining of all functions which
- can be inlined.
-
- You must have the source to the library functions in the appropriate
- directories, e.g. strcpy must be reachable via
-
- #include "vbccm68k:libsrc/string/strcpy.c"
-
- (This could be a problem when cross-compiling.)
-
-
- STDIO
-
- The following functions are implemented at the moment:
-
- fopen() binary and text modes are the same
- fclose()
- fflush()
- fgetc()
- ungetc()
- fputc()
- fgets()
- fputs()
- fread()
- fwrite()
- gets() never use it...
- puts()
- ftell()
- fseek()
- remove()
- rename()
- rewind()
- setvbuf()
- setbuf()
- feof()
- ferror()
- prerror()
- tmpnam()
- tmpfile() always returns an error at the moment
- fgetpos()
- fsetpos()
- printf() taken from libnix; link with a math library if you need fp
- fprintf() "
- sprintf() "
- vprintf() "
- vfprintf() "
- vsprintf() "
- scanf() "
- fscanf() "
- sscanf() "
-
- There are macros for a few functions. Some of them will cause a
- warning 129. This is necessary to make them fully conforming. You can
- safely ignore those warnings or use -dontwarn=129.
-
-
- STDLIB
-
- The following functions do exist.
-
- malloc() uses a variation of the example in K&R;
- currently allocates chunks of at least _nalloc*8 bytes;
- you can set _nalloc after an extern size_t _nalloc;
-
- There is an alternative file (libsrc/stdlib/newmalloc.o)
- which provides malloc(), free() and realloc() functions
- that call the memory pool functions of amiga.lib.
- If you link this file to your program those will be used.
- These functions are probably slower for malloc(), but
- much faster for free(), so if free() is used often it may
- be useful to link with this file.
- _nalloc has a similar meaning here, but chunks of _nalloc
- bytes are allocated rather than _nalloc*8 bytes.
- free()
- calloc()
- realloc()
- rand() taken from libnix
- srand() "
- system() uses SystemTagList or Execute depending on OS version
- abs()
- labs()
- div()
- ldiv()
- abort()
- atexit()
- getenv() taken from libnix
- qsort() "
- bsearch() "
- strtol() "
- strtoul() "
- atol() "
- atoi() "
- atof() taken from libnix; link with a math library to use this
- strtod() "
-
-
- TIME
-
- The standard functions should exist. Taken from libnix.
- clock() always returns -1.
- Link with a math library if you use difftime().
-
-
- STRING
-
- The standard functions should exist.
-
-
- CTYPE
-
- The standard functions should exist.
-
-
- LIMITS
-
- No functions.
-
-
- FLOAT
-
- I do not know what has to be there, yet, but the most important things
- should be there (and approximately correct). No functions.
-
-
- MATH
-
- You have to link with a math library to use these functions.
- The following functions should be there, but they may be not precise
- enough or otherwise not fully ANSI conform in some cases (e.g. errno
- is not set and pow() with m881 is probably not fully conforming):
-
- sin(), cos(), tan()
- sinh(), cosh(), tanh()
- asin(), acos(), atan(), atan2()
- exp(), log(), log10(), pow()
- ceil(), floor()
- sqrt()
- fabs()
- fmod()
- ldexp(). frexp()
-
- If _M68881, _M68040 or _M68060 is #defined when math.h is included
- inline assembly will be generated for certain functions.
-
-
- STDDEF
-
- Currently defines size_t, fpos_t, ptrdiff_t, wchar_t, time_t, clock_t,
- NULL and offsetof. No functions.
-
-
- STDARG
-
- Defines va_list, va_start, va_arg and va_end. Seems to work well, but
- vbcc gives an 'offset equals size of object' warning. No functions.
-
-
- ASSERT
-
- Not really tested yet. No functions.
-
-
- ERRNO
-
- The include file and errno is there, but most functions do not set
- errno. No functions.
-
-
- SETJMP
-
- Oh well...I only wrote down some lines, but never tested it.
- Also I think maybe there should be a special version for fpu, but it
- is not required by the ANSI standard AFAIK.
-
-
- SIGNAL
-
- signal() and raise() are there, but always return an error.
-
-
- LOCALE
-
- localeconv() and setlocale() are there, but setlocale() does not do
- anything.
-
-
- Again, there may be some errors or missing things in the include files
- and the library.
-
-
- COMPILING
-
- If you want to compile the libraries yourself you should be able
- to call the Make#?.script scripts from their directory and the rest
- should be done automatically and the resulting .lib file will be
- copied to vlib: (so take care you do not overwrite another library).
- If you want to create special libraries (e.g. a vc.lib for 020+)
- you have to edit the Make scripts.
- E.g. to create the small-data-vcs.lib change add -sd in the
- alias cc ... line and replace every following vc by vcs.
-
- Currently there is no small-data-version of the math libraries (it
- should not make a difference with m881.lib, but with mieee.lib and
- m040.lib).
-
-
-
- Volker volker@vb.franken.de
-
-